<form th:action="@{/admin/m/base/customField/edit.gsp}" th:object="${result}" class="form-horizontal" id="editFieldForm" role="form" action="#" method="post">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h4 class="modal-title">修改模型</h4>
	</div>
	<div class="modal-body">
		<div class="row">
			<div class="col-md-12">
				<input th:field="*{id}" type="text" hidden="true" /> <input th:field="*{innerType}" type="text" hidden="true" /> <input th:field="*{sortOrder}" type="text" hidden="true" /> <input th:field="*{newline}" type="text" hidden="true" /> <input th:field="*{state}" type="text" hidden="true" />
				<div class="form-group">
					<label class="col-md-3 control-label">字段类型<label class="text-danger">*</label>：
					</label>
					<div class="col-md-7">
						<input th:if="${result.innerType==2}" th:field="*{type}" type="hidden" /> <select th:field="*{type}" th:disabled="${result.innerType==2}" class="form-control">
							<option value="1">文本输入框</option>
							<option value="2">日期输入框</option>
							<option value="3">单选框</option>
							<option value="4">多选框</option>
							<option value="5">文本域</option>
							<option value="6">文本编辑器</option>
							<option value="7">图片上传</option>
							<option value="8">图片集上传</option>
							<option value="9">视频上传</option>
							<option value="10">附件上传</option>
							<option value="11">文库上传</option>
							<option disabled="disabled" value="12">属性控件</option>
						</select>
					</div>
				</div>
				<div class="form-group" id="dateFormatDiv" th:classappend="${result.type==2}?'show':'hide'">
					<label class="col-md-3 control-label">日期格式化：</label>
					<div class="col-md-7">
						<select th:field="*{dateFormat}" th:disabled="${result.innerType==2}" class="form-control">
							<option value="yyyy-MM-dd">yyyy-MM-dd</option>
							<option value="HH:mm:ss">HH:mm:ss</option>
							<option value="yyyy-MM-dd HH:mm:ss">yyyy-MM-dd HH:mm:ss</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">字段标签<label class="text-danger">*</label>：
					</label>
					<div class="col-md-7">
						<input th:field="*{fieldLabel}" placeholder="请输入字段标签" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">字段名称<label class="text-danger">*</label>：
					</label>
					<div class="col-md-7">
						<input th:if="${result.innerType==2}" th:field="*{fieldName}" type="hidden" /> <input th:disabled="${result.innerType==2}" th:field="${result.fieldName}" placeholder="请输入字段名称" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">是否必填：</label>
					<div class="col-md-7">
						<label class="radio-inline"> <input type="radio" th:checked="${result.required==1}" value="1" name="required" id="inlineRadio1" />是
						</label> <label class="radio-inline"> <input type="radio" th:checked="${result.required==2}" value="2" name="required" id="inlineRadio2" />否
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">默认值：</label>
					<div class="col-md-7">
						<input th:field="*{fieldDefaultValue}" placeholder="请输入默认值" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">最大长度：</label>
					<div class="col-md-7">
						<input th:field="*{fieldMaxLength}" placeholder="请输入最大长度" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-3 control-label">提示信息：</label>
					<div class="col-md-7">
						<input th:field="*{prompt}" placeholder="请输入提示信息" type="text" class="form-control" />
					</div>
				</div>
				<div class="form-group" id="checkboxOptionsDiv" th:classappend="${result.type==3 or result.type==4}?'show':'hide'">
					<label class="col-md-3 control-label">可选项：</label>
					<div class="col-md-7">
						<textarea th:field="*{checkboxOptions}" th:disabled="${result.type!=3 and result.type!=4}" th:placeholder="请输入可选项" rows="4" type="text" class="form-control"></textarea>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-primary" type="submit">
			<strong>提 交</strong>
		</button>
		<button type="button" class="btn btn-default" data-dismiss="modal">
			<strong>关 闭</strong>
		</button>
	</div>
</form>
<script th:inline="javascript">
    /*<![CDATA[*/
    $(function() {
        var rules = {
            type : {
                required : true
            },
            fieldLabel : {
                required : true,
                maxlength : 20

            },
            fieldName : {
                required : true,
                maxlength : 20
            },
            required : {
                required : true
            },
            fieldDefaultValue : {
                maxlength : 20
            },
            fieldMaxLength : {
                digits : true,
                range : [ 1, 200 ]
            },
            prompt : {
                maxlength : 20
            },
            checkboxOptions : {
                maxlength : 200
            }
        }
        var messages = {

        }
        modelTable.add('customFieldWin', 'editFieldForm', rules, messages);

        $('#editFieldForm select[name="type"]').change(function() {
            var typeVal = $(this).val();
            if (typeVal == 2) {
                $('#dateFormatDiv').removeClass('hide').addClass('show');
                $('#dateFormatDiv select').removeAttr('disabled');
            } else {
                $('#dateFormatDiv').removeClass('show').addClass('hide');
                $('#dateFormatDiv select').attr('disabled', 'disabled');
            }
            if (typeVal == 3 || typeVal == 4) {
                $('#checkboxOptionsDiv').removeClass('hide').addClass('show');
                $('#checkboxOptionsDiv textarea').removeAttr('disabled');
            } else {
                $('#checkboxOptionsDiv').removeClass('show').addClass('hide');
                $('#checkboxOptionsDiv textarea').attr('disabled', 'disabled');
            }
        });
        var innerType = /*[[${result.innerType}]]*/'innerType';
        if (innerType == 1) {
            var type = /*[[${result.type}]]*/'type';
            var str = "";
            if (type == 1 || type == 3 || type == 4 || type == 5 || type == 7 || type == 8 || type == 9 || type == 10 || type == 11) {
                str = "cus_str_";
            } else if (type == 2) {
                str = "cus_date_";
            } else {
                str = "cus_blob_";
            }
            var fieldNameVal = $('#editFieldForm input[name="fieldName"]').val().replace(str, "");
            $('#editFieldForm input[name="fieldName"]').val(fieldNameVal);
        }
    });
    /*]]>*/
</script>
